home *** CD-ROM | disk | FTP | other *** search
- #include "speech.proto.h"
- #include "rsdefs.h"
-
-
- void SpeakStream(unsigned char *ptr, short len)
- {
- OSErr err;
-
- do {
- if (!gCanSpeak) {
- break;
- }
-
- /* Stop the old speech channel */
-
- StopSpeaking();
-
- /* Get a speech channel */
-
- gSpeakingVoiceIndex = gSelectedVoiceIndex;
- MoveHHi((Handle)gVoices);
- HLock((Handle)gVoices);
- err = NewSpeechChannel(&(*gVoices)[gSpeakingVoiceIndex], &gSpeechChannel);
- HUnlock((Handle)gVoices);
- if (noErr != err) {
-
- /* The voice that the user selected doesn't work; let's try the rest */
-
- HLock((Handle)gVoices);
- for (gSpeakingVoiceIndex = 0; gSpeakingVoiceIndex < gNumberVoices; gSpeakingVoiceIndex++) {
- err = NewSpeechChannel(&(*gVoices)[gSpeakingVoiceIndex], &gSpeechChannel);
- if (noErr == err) {
- break;
- }
- }
- HUnlock((Handle)gVoices);
- if (gSpeakingVoiceIndex == gNumberVoices) {
- StopSpeaking();
- break;
- }
- }
-
- /* Start speaking the new text */
-
- err = SpeakText(gSpeechChannel, (char *)ptr, len);
- if (noErr != err) {
- StopSpeaking();
- break;
- }
-
- /* Flash the selection, and fix the menu */
-
- while (SpeechBusy()) {
- }
-
-
- } while (false);
-
- if (noErr != err) {
- DoSpeechError(err);
- }
- }